import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import http from "@/plugins/http";
import "nprogress/nprogress.css";
// import utils from "@/plugins/utils.js";
import NProgress from "nprogress";
// 按需引入 

// 引入重置样式表
import "@/assets/css/reset.css"
// 引入fontawesome   不靠谱 难用
// import { library } from '@fortawesome/fontawesome-svg-core'
// import { 
//   faUser,
//   faUnlockAlt
// } from '@fortawesome/free-solid-svg-icons'
// import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
// library.add(faUser,faUnlockAlt)

// Vue.component('font-awesome-icon', FontAwesomeIcon)
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
// 引入fonticon  阿里巴巴图标库
import "./assets/iconfont/iconfont.css"
// 引入公共样式
// 折线图
import VeLine from "v-charts/lib/line.common.js"
// 柱状图
import VeBar from "v-charts/lib/bar.common.js"
// 饼图
import VePie from "v-charts/lib/pie.common.js"
// 环图
import VeRing from "v-charts/lib/ring.common.js"
import "@/assets/css/common.css"

import './plugins/element.js'
// import utils from './plugins/utils';

Vue.config.productionTip = false;
Vue.prototype.$http = http;

NProgress.configure({     
  easing: 'ease',  // 动画方式    
  speed: 500,  // 递增进度条的速度    
  showSpinner: false, // 是否显示加载ico    
  trickleSpeed: 200, // 自动递增间隔    
  minimum: 0.3 // 初始化时的最小百分比
});
// 使用组件
Vue.component(VeLine.name, VeLine);
Vue.component(VeBar.name,VeBar);
Vue.component(VePie.name,VePie);
Vue.component(VeRing.name,VeRing);


// 跳转之前执行
router.beforeEach((to,from,next)=>{
  NProgress.start();
  // 获取token
  let token = window.localStorage.getItem("token") ? window.localStorage.getItem("token") : "";
  if(token || to.path=="/login"){
      next();
  }else{
    NProgress.done();
    next({path:"/login"});
  }
});
// 路由跳转完成后
router.afterEach((to, from)=>{
  NProgress.done();
});


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')